﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Linq.Expressions;
using ASPItalia.ModelVirtualCasting.Common;
using ASPItalia.ModelVirtualCasting.ObjectModel;
using ASPItalia.ModelVirtualCasting.Parts;

namespace ASPItalia.ModelVirtualCasting.Fake
{
	[Export("CountryRepository", typeof(ICountryRepository))]
	[PartCreationPolicy(CreationPolicy.NonShared)]
	[RepositoryMetadata(Name = "CountryRepository", IsFake = true)]
	public class CountryRepository : BaseRepository<ICountryRepository>, ICountryRepository
	{
		protected List<Country> List;

		public CountryRepository()
		{
			this.List = new List<Country>()
            {
                new Country { CountryID = 1, CountryName = "Italia" },
                new Country { CountryID = 2, CountryName = "Francia" },
                new Country { CountryID = 3, CountryName = "Regno Unito" },
                new Country { CountryID = 4, CountryName = "Stati Uniti d'America" }
            };
		}

		public IQueryable<Country> GetAll()
		{
			return this.List.AsQueryable();
		}

		public IQueryable<Country> Where(Expression<Func<Country, bool>> predicate)
		{
			return this.List.AsQueryable().Where<Country>(predicate);
		}

		public long Count(System.Linq.Expressions.Expression<Func<Country, bool>> predicate)
		{
			return this.List.AsQueryable().Where<Country>(predicate).Count();
		}

		public Country GetByID(int countryId)
		{
			return this.Where(c => c.CountryID == countryId).Single();
		}

		public ICountryRepository EnableLazyLoading()
		{
			return this;
		}

		public ICountryRepository DisableLazyLoading()
		{
			return this;
		}

		public ICountryRepository Include(string path)
		{
			return this;
		}


		public ICountryRepository Include<TProperty>(Expression<Func<Country, TProperty>> path)
		{
			return this;
		}

		public ICountryRepository CreateQuery()
		{
			return this;
		}

		public ICountryRepository DoNotTrack()
		{
			return this;
		}
	}
}